package ExamLab.Test3;

public class Syn extends Thread {

	static void doSleep(long t) {
		try {
			Thread.sleep(t);
		} catch (Exception e) {
		}
	}

	public void run() {
		synchronized (System.in) {
			synchronized (this) {
				System.out.print("A");
				doSleep(500);

				try {
					wait();
				} catch (Exception e) {
				}

				System.out.print("B");
			}
			doSleep(500);
			System.out.print("C");
		}
	}

	public static void main(String args[]) {
		Syn s1 = new Syn();
		System.out.print("D");
		doSleep(500);
		s1.start();
		doSleep(2000);

		synchronized (s1) {
			s1.notifyAll();
			doSleep(2000);
			System.out.print("E");
		}
	}
}
